<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ taglib prefix="webtag" uri="http://www.iflexsys.tagslib.com.vn"%>
<%@ page language="java" contentType="text/html; charset=utf-8"
	pageEncoding="utf-8" isELIgnored="false"%>
<html>
<head>
<!--  date picker script -->
<script type="text/javascript" charset="utf-8">
	$(function() {
		// initialise the "Select date" link
		$("#seDate")
				.datepicker(
						// associate the link with a date picker
						{
							showOn : 'button',
							buttonImage : '<spring:theme code="theme.admin.images"/>/calendar.gif',
							buttonImageOnly : true,
							changeMonth : true, // must be disabled when using maxDate
							changeYear : true,
						//onSelect:function(selectedDate){
						//alert("as");
						//your_function(selectedDate);
						//}
						});
		$("#datepicker").datepicker();
		$('.askDelBook').jConfirmAction();
	});
</script>
<!--end form -->
<title>Thông tin sách</title>
</head>
<body>
	<div>
		<form id="searchBook" action="searchBook" method="POST">
			
			<h2>Thông tin sách</h2>
			<input type="image" class="search_submit" src="<spring:theme code="theme.admin.images"/>/search.png" />
			<input type="text" name="keyword" class="search_input" placeholder="search keyword" value="${keyword}"/> 
			<select class="search_checkbox" name="typeSearch">
				<c:if test="${typeSearch == '' }">
					<option value="" selected="selected">Tìm kiếm theo</option>
				</c:if>
				<c:if test="${typeSearch != '' }">
					<option value="">Tìm kiếm theo</option>
				</c:if>
				
				<c:if test="${typeSearch == 'name' }">
					<option value="name" selected="selected">Tên Sách</option>
				</c:if>
				<c:if test="${typeSearch != 'name' }">
					<option value="name">Tên Sách</option>
				</c:if>
				
				<c:if test="${typeSearch == 'category' }">
					<option value="category" selected="selected">Loại Sách</option>
				</c:if>
				<c:if test="${typeSearch != 'category' }">
					<option value="category">Loại Sách</option>
				</c:if>
				
				<c:if test="${typeSearch == 'author' }">
					<option value="author" selected="selected">Tác giả</option>
				</c:if>
				<c:if test="${typeSearch != 'author' }">
					<option value="author">Tác giả</option>
				</c:if>
				
			</select>
			<input type="hidden" id="pageIndexId" name="pageIndex" value="1">
		</form>
		<%-- <form style="margin-right: 35px;">
			<h2>Thông tin sách</h2>
			<input type="image" class="search_submit" src="<spring:theme code="theme.admin.images"/>/search.png" />
			<input type="text" name="" class="search_input"
				value="search keyword" onclick="this.value=''" /> <select
				class="search_checkbox">
				<option value="name">Tên Sách</option>
				<option value="category">Loại Sách</option>
				<option value="author">Tác giả</option>
			</select>


		</form> --%>
	</div>

	<table id="rounded-corner" class="tableContent">
		<thead>
			<tr>
				<th scope="col" class="rounded-company"></th>
				<th scope="col" class="rounded">Tên sách</th>
				<th scope="col" class="rounded">Loại sách</th>
				<th scope="col" class="rounded">Tác giả</th>
				<th scope="col" class="rounded">Giá</th>
				<th scope="col" class="rounded">Trạng thái</th>
				<th scope="col" class="rounded">Chi tiết</th>
				<th scope="col" class="rounded">Sửa</th>
				<th scope="col" class="rounded-q4">Xóa</th>
			</tr>
		</thead>
		<c:choose>
			<c:when test="${empty listBook}">
				<tfoot><tr> <td colspan="8" align="center">Không tìm thấy bản ghi nào phù hợp </td></tr></tfoot>
			</c:when>
			<c:otherwise>
				<tbody>
				<c:forEach var="book" items="${listBook}">
				<tr>
					<td></td>
					<td>${book.name}</td>
					<td>
						<c:forEach items="${bookTypeList }" var="bookType">
							<c:if test="${book.bookTypeId == bookType.id}">
								${bookType.name }
							</c:if>
						</c:forEach>
					</td>
					<td>${book.author }</tdbook>
					<td>${book.price}</td>
					<td>
						<c:choose>
							<c:when test="${book.active == 1}">Hiển thị</c:when>
							<c:otherwise>Không hiển thị</c:otherwise>
						</c:choose>
					</td>
					<td><a class="fancyboxDemo"
								href="ajax/viewDetailBook?id=${book.id}">Xem</a></td>
					<td>
						<a href="edit-book?id=${book.id}">
							<img src="<spring:theme code="theme.admin.images"/>/user_edit.png" alt="" title="" border="0" />
						</a>
					</td>
					<td><a href="delete-book?bookId=${book.id}" class="askDelBook">
						<img src="<spring:theme code="theme.admin.images"/>/trash.png"
						alt="" title="" border="0" />
					</a></td>
				</tr>
				</c:forEach>
				<tbody>
			</c:otherwise>
		</c:choose>
	</table>

	<c:if test="${fn:length(listBook) > 0}">
		<div class="pagination">
			<webtag:pagination pagingInfo="${pagingInfo}"
				pageIndexId="pageIndexId" formId="searchBook" />
		</div>
	</c:if>
</body>
</html>